﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using QuantitativeInvestment.Bean;
namespace QuantitativeInvestment.StockPool
{
    class DFZQStockPool:StockPool
    {

        public SqlConnection windConnection; // 数据库连接dd
        public SqlCommand windCommand; //数据库连接命令
        public DFZQStockPool()
        {
            this.windConnection = new SqlConnection("Server=localhost; User=sa; PWD=111111;database=DFZQ;Asynchronous Processing=true");
            this.windConnection.Open();
            this.windCommand = this.windConnection.CreateCommand();
            this.poolName="东方证券股票池";


        }
        public override List<TradingStock> getStocks(string tradingDate)
        {
          
            List<TradingStock> stocks = new List<TradingStock>();
            windCommand.CommandText = "SELECT distinct [code],name FROM [DFZQ].[dbo].[DFZQ_Ratings] where startDate<=" + tradingDate + " and endDate>=" + tradingDate;
            SqlDataReader sdr = windCommand.ExecuteReader();
            while (sdr.Read())
            {
                TradingStock stock = new TradingStock(sdr["code"].ToString(), sdr["name"].ToString());
                stocks.Add(stock);
            }
            sdr.Close();
            return stocks;

        }
    }
}
